/*
 * Copyright (c) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

let ASSERT_EQ = function assertEq(v0, v1) {
    if (!Object.is(v0, v1)) {
        let msg = `ASSERTION FAILED: ${v0}[${typeof v0}] !== ${v1}[${typeof v1}]`;
        throw Error(msg);
    }
};

export function checkResult(ptr) {
    let test = requireNapiPreview('serialize_interop_tests_module', true);
    let o2 = test.napiDeserialize(ptr);
    ASSERT_EQ(o2.testClass.testStaticMethod(), 'testStaticMethod');
    ASSERT_EQ(o2.testClass.staticProp, 'staticProp');
    ASSERT_EQ(new o2.testClass().prop, 'prop');
    ASSERT_EQ(new o2.testClass().testMethod(), 'testMethod');
    ASSERT_EQ(o2.testArray[0], 'testArrayElement');
    ASSERT_EQ(o2.testInstance.prop, 'prop');
    ASSERT_EQ(o2.testFunction(), 'testFunction');
    ASSERT_EQ(o2.testDynamicInstance.a, 1);
}